package com.kaishengit.web;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.kaishengit.entity.Goal;
import com.kaishengit.entity.Project;
import com.kaishengit.entity.User;
import com.kaishengit.service.GoalService;
import com.kaishengit.service.ProjectService;
import com.kaishengit.service.UserService;

public class NewTaskView extends HttpServlet {

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		request.setCharacterEncoding("UTF-8");
		
		String goalname = request.getParameter("goalname");
			
		if(goalname!=null) {
			request.setAttribute("goalname", goalname);
		}
		
		String projectname = request.getParameter("projectname");
		
		if(projectname!=null) {
			request.setAttribute("projectname", projectname);
		}
		String state = request.getParameter("state");
		
		request.setAttribute("state",state);
		
		UserService userService = new UserService();
		
		List<User> listuser = userService.findAll();
		
		
		ProjectService projectService = new ProjectService();
		
		List<Project> listproject = projectService.findAll();
		
		
		GoalService goalService = new GoalService();
		
		List<Goal> listgoal = goalService.findAll();
		
		request.setAttribute("listproject", listproject);
		request.setAttribute("listgoal", listgoal);
		request.setAttribute("listuser", listuser);
		
		// TODO Auto-generated method stub
		request.getRequestDispatcher("WEB-INF/views/newtask.jsp").forward(request, response);
	}

}
